<template>
     <div class="container" v-loading="dataListLoading">
        <div class="cons zl-dialog">
            <div class="con-title cbtitle-font">班级信息</div>  
            <div class="con-item">   
                <div class="lie-title mtitle-font mtitle-color"><span class="red-x">*</span>班级名称</div>
                <el-input class="text-input covered addInput"  minlength="1" maxlength="50"  v-model="classEntity.className" placeholder="" clearable></el-input>
                <!-- <div class="ts-text">请按照“学年+地区+考试@题号”的格式填写，例如：2013石景山期末@33</div> -->
            </div>
            <div class="con-item">
                <div class="lie-title mtitle-font mtitle-color"><span class="red-x">*</span>学年</div>
                <el-select placeholder="请选择"  v-model="classEntity.yearly">
                    <el-option  v-for="(item, index) in yearlist" :key="index" :label="item.key" :value="item.value"></el-option>
                </el-select>
                
            </div>
            <div class="con-item ">
                <div class="lie-title mtitle-font mtitle-color"><span class="red-x">*</span>年级</div>
                <el-select placeholder="请选择"  v-model="classEntity.grade" clearable>
                    <el-option  label="高三" value="17"></el-option>
                    <el-option  label="高二" value="14"></el-option>
                    <el-option  label="高一" value="11"></el-option>
                </el-select>
            </div>
            <div class="con-item">
                <div class="lie-title mtitle-font mtitle-color"><span class="red-x">*</span>业绩中心</div>
                <el-select placeholder="请选择"  v-model="classEntity.areaId" @change="changeArea" clearable>
                    <el-option  v-for="(item, index) in areaList" :key="index" :label="item.key" :value="item.value"></el-option>
                </el-select>
            </div>
            <div class="con-item">
                <div class="lie-title mtitle-font mtitle-color"><span class="red-x">*</span>授课地点</div>
                <el-select placeholder="请选择"  v-model="classEntity.officeId" clearable>
                    <el-option  v-for="(item, index) in officeList" :key="index" :label="item.key" :value="item.value"></el-option>
                </el-select>
            </div>
            <div class="con-item">
                <div class="lie-title mtitle-font mtitle-color"><span class="red-x">*</span>产品线</div>
                <el-select placeholder="请选择"  v-model="classEntity.productId" clearable>
                    <el-option  v-for="(item, index) in productList" :key="index" :label="item.key" :value="item.value"></el-option>
                </el-select>
            </div>
            <div class="con-item">
                <div class="lie-title mtitle-font mtitle-color"><span class="red-x">*</span>额定人数</div>
                <!-- <el-input class="text-input covered addInput"  v-enter-number  v-model="classEntity.totalNum" placeholder="" maxlength="10" clearable></el-input> -->
                <input-number v-model="classEntity.totalNum" :min="0" class="text-input addInputs mtitle-font" :maxLength="10"></input-number>
            </div>
            <div class="con-item">
                <div class="lie-title mtitle-font mtitle-color"><span class="red-x">*</span>课酬班型</div>
                <el-select placeholder="请选择"  v-model="classEntity.salaryType" clearable>
                    <el-option  label="标准班" value="0"></el-option>
                    <el-option  label="精粹班" value="1"></el-option>
                </el-select>
            </div>
            <div class="con-item">
                <div class="lie-title mtitle-font mtitle-color"><span class="red-x">*</span>班级类型</div>
                <el-select placeholder="请选择"  v-model="classEntity.classType" @change="changeClassType" clearable>
                    <el-option  label="行政班" value="0"></el-option>
                    <el-option  label="教学班" value="1"></el-option>
                </el-select>
            </div>
            <div class="con-item">
                <div class="lie-title mtitle-font mtitle-color"><span class="red-x">*</span>班级班型</div>
                <el-select placeholder="请选择"  v-model="classEntity.classLevelType" clearable>
                    <el-option  v-for="(item, index) in classLevelList" :key="index" :label="item.key" :value="item.value"></el-option>
                </el-select>
            </div>
            <div class="con-item">
                <div class="lie-title mtitle-font mtitle-color"><span class="red-x">*</span>试卷类型</div>
                <el-select placeholder="请选择"  v-model="classEntity.paperType" clearable>
                    <el-option  label="北京卷" value="0"></el-option>
                    <el-option  label="全国卷" value="1"></el-option>
                </el-select>
            </div>
            <div class="con-item">
                <div class="lie-title mtitle-font mtitle-color"><span class="red-x">*</span>班级科目</div>
                <el-select placeholder="请选择" v-model="classEntity.subjectType" clearable> 
                    <template v-if="classEntity.classType == 0">
                        <el-option label="主三科" :value="2"></el-option>
                        <el-option label="主三科+物化生" :value="1"></el-option>
                        <el-option label="主三科+史地政" :value="0"></el-option>
                        <el-option label="主三科+物化生史地政" :value="3"></el-option>
                    </template>                      
                    <template v-if="classEntity.classType == 1">
                        <el-option label="物理" :value="4"></el-option>
                        <el-option label="化学" :value="5"></el-option>
                        <el-option label="生物" :value="6"></el-option>
                        <el-option label="历史" :value="7"></el-option>
                        <el-option label="地理" :value="8"></el-option>
                        <el-option label="政治" :value="9"></el-option>
                    </template>                        
                </el-select>
            </div>
            <div class="con-item">
                <div class="lie-title mtitle-font mtitle-color"><span class="red-x">*</span>状态</div>
                <el-select placeholder="请选择" class="zl-dialog" v-model="classEntity.status" clearable>
                    <el-option  label="正常" value="1"></el-option>
                    <el-option  label="停用" value="0"></el-option>
                </el-select>
            </div>
            <div class="con-item">
                <div class="lie-title mtitle-font mtitle-color">所在教室</div>
                <el-input class="covered addInput" v-model="classEntity.doorPlate" placeholder="" clearable></el-input>
                <el-button class="add" @click="addClassroom">添加</el-button>
            </div>
            <div class="con-item">
                <div class="lie-title mtitle-font mtitle-color"><span class="red-x">*</span>关联上课周期</div>
                <el-input class="covered addInput" v-model="classEntity.courseCycName" placeholder="" clearable></el-input>
                <el-button class="add" @click="addCourseCyc">添加</el-button>
            </div>
            <div class="div-btn" style="padding-bottom: 10px" >
                <el-button class="el-btn" type="primary" @click="toSave()" :disabled="saveStatus">保存</el-button>
                <el-button class="el-btn" @click="toXiao()" :disabled="saveStatus">取消</el-button>
            </div>
        </div>
     
        <el-dialog title="选择所在教室" dialogDrag v-model="classroomDialog.dialogVisible" width="50%" :close-on-click-modal="false">
            <div class="el-dialog-div">
                <div>
                    <span class="nine-line-title">办公地点</span>
                    <el-select placeholder="请选择"  v-model="classroomDialog.officeId" clearable>
                        <el-option  v-for="(item, index) in officeList" :key="index" :label="item.key" :value="item.value"></el-option>
                    </el-select>
                    <el-button style="margin-left:10px;" @click="searchClassroom()">查询</el-button>
                </div>
                <el-table
                    :data="classroomDialog.tableData" 
                    border
                    highlight-current-row 
                    height="320px"
                    class="table" 
                    ref="multipleTable" 
                    :header-cell-style="{background: '#f1f1f1', color: '#333'}" width="100%">
                    <el-table-column prop="doorPlate" header-align="center" align="center" label="教室门牌号"></el-table-column>
                    <el-table-column prop="maxCount" header-align="center"  align="center"  label="最大容量" > </el-table-column>
                    <el-table-column prop="floor" header-align="center" align="center" label="楼层"></el-table-column>
                    <el-table-column prop="officeName" header-align="center" align="center" label="办公地点"></el-table-column>
                    <el-table-column  header-align="center" align="left" label="操作" width="90">
                        <template #default="scope">
                            <el-button link type="primary" size="small" @click="confirmClassroom(scope.$index, scope.row)"><el-icon><Edit /></el-icon>确认</el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </div>
           
        </el-dialog>   
            
        <el-dialog title="选择上课周期" v-model="courseCycDialog.dialogVisible" dialogDrag width="70%" :close-on-click-modal="false">
            <div class="el-dialog-div">
                <el-table
                    :data="courseCycDialog.tableData" 
                    border
                    highlight-current-row 
                    class="table" 
                    ref="multipleTable" 
                    :header-cell-style="{background: '#f1f1f1', color: '#333'}" width="100%">
                    <el-table-column prop="name" header-align="center" align="center" label="上课周期名字"></el-table-column>
                    <el-table-column prop="areaName" header-align="center"  align="center" label="上课学区" > </el-table-column>
                    <el-table-column prop="yearly" header-align="center" align="center" label="学年"></el-table-column>
                    <el-table-column prop="productName" header-align="center" align="center" label="三级产品线"></el-table-column>
                    <el-table-column prop="cycle" header-align="center" align="center" label="上课周期"></el-table-column>
                    <el-table-column prop="weakNum" header-align="center" align="center" label="周次数"></el-table-column>
                    <el-table-column  header-align="center" align="left" label="操作" width="90">
                        <template #default="scope">
                            <el-button link type="primary" size="small" @click="confirmCourseCyc(scope.$index, scope.row)"><el-icon><Edit /></el-icon>选择</el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </div>
           
        </el-dialog>
    </div>
</template>

<script setup lang="ts">
import {crmUrl} from '@/utils/api';  
import bus from '../../../common/bus';
import inputNumber from '@/components/common/input-number.vue';
import { getCurrentInstance, onActivated, onMounted, reactive, ref } from 'vue';
import { onBeforeRouteLeave, useRoute, useRouter } from 'vue-router';
import baseService from '@/service/baseService';
import { useAppStore } from '@/store';
let yearlist = ref([]);
let areaList= ref([]);
let officeList= ref([]);
let productList= ref([]);
let tagsList= ref([]);
let classLevelList= ref([]);//班级班型列表
let classroomDialog = reactive({
    dialogVisible:false,
    officeId:'',
    tableData:[]
});
let courseCycDialog = reactive({
    dialogVisible:false,
    tableData:[]
});
let saveStatus = ref(false);
let classEntity = reactive({
    classId:'',
    className:'',
    gradeStr:'',
    grade:'',
    areaId:'',
    officeName:'',
    officeId:'',
    classType:'',
    classLevelType:'',
    subjectType:'',
    status:'1',
    masterId:'',
    realname:'',
    yearly:'',
    productId:'',
    productName:'',
    paperType:'',
    classroomId:'',
    doorPlate:'',
    courseCycId:'',
    courseCycName:'',
    salaryType:'',
    totalNum:'',
    source:0
});
let dataListLoading = ref(false);
let isDel = ref(false);
let router = useRouter();
let route = useRoute();
let store = useAppStore();
//获取上下文实例，ctx=vue2的this
const { ctx,proxy } = getCurrentInstance();
onMounted(()=>{
    getSessionSearch();
})
let getSessionSearch= ()=>{
    getAreaList();
    getYears();
    getProductList();
    tagsList.value = store.state.tagsLists;
    getDictionList()
};
let closeTab=()=>{
    for (let i = 0, len = tagsList.value.length; i < len; i++) {
        const item = tagsList.value[i];
        if(item.path === route.fullPath){
            tagsList.value.splice(i, 1);
            store.state['tagsLists'] = tagsList.value;
            break;
        }
    }
};
let getYears=()=>{
    //获取学年
    baseService.post(crmUrl+'/ft/campus/getSchoolYearList.do')
        .then(res => {
            if(res.data!=null&&res.data.code==0){
                //获取菜单列表
            yearlist.value = res.data.data;
            yearlist.value.forEach(element => {
                if( element.status == 1){
                    classEntity.yearly = element.value;
                }
            });
            }else{
                yearlist.value = [];
            }
    }, err => {
       return proxy.$message.error(err);
    });
};
let getProductList=()=>{
    //获取产品线列表
    baseService.post(crmUrl+'/ft/campus/getProductList.do')
        .then(res => {
            if(res.data.code==0){
                //获取菜单列表
                productList.value = res.data.data;
            }else{
                productList.value = [];
            }
    }, err => {
        return proxy.$message.error(err);
    });
};
let getAreaList=()=>{
    //业绩中心
    baseService.post(crmUrl+'/ft/campus/getSchoolAreaList.do')
        .then(res => {
            areaList.value = res.data.data;
    }, err => {
        return proxy.$message.error(err);
    });
};
let changeArea=()=>{
    officeList.value = [];
    classEntity.officeId = '';
    if(classEntity.areaId){
        let param = new URLSearchParams();
        param.append("areaId",classEntity.areaId);
        //授课地点
        baseService.post(crmUrl+'/ft/campus/getOffices.do',param)
            .then(res => {
                officeList.value = res.data.data;
        }, err => {
            return proxy.$message.error(err);
        });
    }
};
let changeClassType=()=>{
    classEntity.subjectType = '';
};           
//获取字典表
let getDictionList=()=>{
    classLevelList.value = [];//班级班型
    let param = new URLSearchParams();
    param.append('type', '162');
    baseService.post(crmUrl + '/ft/ftchoose/getDictionaryByType.do', param).then(res => {
        //获取菜单列表
        if(res.data.code == 0){
            classLevelList.value = res.data.data;
        }
    }, err => {
        return proxy.$message.error(err);
    });
};
let addClassroom=()=>{
    if(!classEntity.yearly){
        return proxy.$message.error('请先选择学年');
    }

    if(!classEntity.officeId ){
        return proxy.$message.error('请先选择授课地点');
    }
    if(!classEntity.classType){
        return proxy.$message.error('请先选择班级类型');
    }
    classroomDialog.officeId = classEntity.officeId;
    let param = new URLSearchParams();
    param.append("yearly", classEntity.yearly);
    param.append("officeId", classroomDialog.officeId);
    param.append("classType", classEntity.classType);
    baseService.post(crmUrl+'/ft/campus/getClassroom.do',param)
        .then(res => {
            classroomDialog.tableData = res.data.data;
            classroomDialog.dialogVisible = true;
    }, err => {
        return proxy.$message.error(err);
    });
};
let addCourseCyc=()=>{
    if(!classEntity.yearly){
        return proxy.$message.error('请先选择学年');
    }
    let param = new URLSearchParams();
    param.append("yearly",classEntity.yearly);
    if(!classEntity.productId){
        param.append("productId",classEntity.productId);
    }
    if(!classEntity.officeId){
        param.append("officeId",classEntity.officeId);
    }
    baseService.post(crmUrl+'/ft/schoolcourse/getCourseCycleList.do',param)
        .then(res => {
            courseCycDialog.tableData = res.data.data;
            courseCycDialog.dialogVisible = true;
    }, err => {
        proxy.$message.error(err);
        // proxy.$message.error('数据请求出错')
    });
};
let toSave=()=>{
    saveStatus.value = true;
    if(!classEntity.className){
        proxy.$message.error('请填写班级名称');
        saveStatus.value = false;
        return false;
    }
    if(!classEntity.yearly){
        proxy.$message.error('请选择学年');
        saveStatus.value = false;
        return;
    }
    if(!classEntity.grade){
        proxy.$message.error('请选择年级');
        saveStatus.value = false;
        return;
    }
    if(!classEntity.areaId){
        proxy.$message.error('请选择业绩中心');
        saveStatus.value = false;
        return;
    }
    if(!classEntity.officeId){
        proxy.$message.error('请选择授课地点');
        saveStatus.value = false;
        return;
    }
    if(!classEntity.productId){
        proxy.$message.error('请选择产品线');
        saveStatus.value = false;
        return;
    }
    if(!classEntity.totalNum){
        proxy.$message.error('请填写额定人数');
        saveStatus.value = false;
        return;
    }
    if(!classEntity.salaryType){
        proxy.$message.error('请选择课酬类型');
        saveStatus.value = false;
        return;
    }
    if(!classEntity.classType){
        proxy.$message.error('请选择班级类型');
        saveStatus.value = false;
        return;
    }
    if(!classEntity.classLevelType){
        proxy.$message.error('请选择班级班型');
        saveStatus.value = false;
        return;
    }
    if(!classEntity.paperType){
        proxy.$message.error('请选择试卷类型');
        saveStatus.value = false;
        return;
    }
    if(!classEntity.subjectType && classEntity.subjectType!=0){
        proxy.$message.error('请选择班级科目');
        saveStatus.value = false;
        return;
    }
    if(classEntity.classType == 0){
        if(!classEntity.subjectType  && classEntity.subjectType!=0){
            proxy.$message.error('请选择班级科目');
            saveStatus.value = false;
            return;
        }
        if(classEntity.subjectType > 3){
            proxy.$message.error('行政班不能选择单科');
            saveStatus.value = false;
            return;
        }

    }else if((classEntity.subjectType || classEntity.subjectType==0) && classEntity.subjectType < 3){
        proxy.$message.error('教学班只能选择单科');
        saveStatus.value = false;
        return;
    }
    if(!classEntity.status){
        proxy.$message.error('请选择状态');
        saveStatus.value = false;
        return;
    }
    if(!classEntity.doorPlate){
        classEntity.classroomId = '';
    }
    if(classEntity.classType == 0 &&  !classEntity.classroomId ){
        proxy.$message.error('请选择所在教室');
        saveStatus.value = false;
        return;
    }
    if(!classEntity.courseCycId){
        proxy.$message.error('请关联上课周期');
        saveStatus.value = false;
        return;
    }
    let param = new URLSearchParams();
    dataListLoading.value=true;
    param.append("className",classEntity.className);
    param.append("classType",classEntity.classType);
    param.append("bjbx",classEntity.classLevelType);
    param.append("grade",classEntity.grade);
    param.append("officeId",classEntity.officeId);
    param.append("areaId",classEntity.areaId);
    param.append("salaryType",classEntity.salaryType);
    param.append("studentNums",classEntity.totalNum);
    param.append("yearly",classEntity.yearly);
    param.append("productId",classEntity.productId);
    param.append("status",classEntity.status);
    param.append("paperType",classEntity.paperType);
    param.append("source",0);
    if(classEntity.classroomId){
        param.append("classroomId",classEntity.classroomId);
    }
    param.append("courseCycId",classEntity.courseCycId);
    param.append("subjectType",classEntity.subjectType);
    baseService.post(crmUrl+'/ft/classmanage/saveClass.do',param)
        .then(res => {
            dataListLoading.value= false;
            if(res.data.code === 0){
                //保存成功
                proxy.$message.success("保存成功！")
                //返回前一个页面
                closeTab();
                isDel.value = true;
                saveStatus.value = false;
                router.push('/showqrzclassmanage')
            }else{
                proxy.$message.error(res.data.msg);
                saveStatus.value = false;
                //留在当前页面
            }
    }, err => {
        proxy.$message.error(err);
        // proxy.$message.error('数据请求出错！')
        saveStatus.value = false;
        //this.closeTab();
        //返回前一个页面
        router.push('/showqrzclassmanage')
    });

};
let confirmClassroom=(index,row)=>{
    classEntity.classroomId = row.classroomId;
    classEntity.doorPlate = row.doorPlate;
    classroomDialog.dialogVisible = false;

};
let confirmCourseCyc=(index,row)=>{
    classEntity.courseCycId = row.id;
    classEntity.courseCycName = row.name;
    courseCycDialog.dialogVisible = false;
};
let checkNum=()=>{
    let patern = /^(\-|\+)?\d+(\.\d+)?$/;//验证正数、负数、小数
    let font = classEntity.totalNum + '';
    if(font.endsWith('.') ){
        font = font.substr(0,font.length-1);
    }
    if(font.indexOf('.')==0){
        if(!patern.test(parseFloat(font))){
            classEntity.totalNum = '';
        }
    }else{
        if(!patern.test(parseInt(font))){
            classEntity.totalNum = '';
        }
    }
};
let searchClassroom=()=>{
        if(!classroomDialog.officeId){
        proxy.$message.error('请先选择办公地点');
        return;
    }
    let param = new URLSearchParams();
    if(classEntity.yearly){
        param.append("yearly",classEntity.yearly);
    }
    param.append("officeId",classroomDialog.officeId);
    if(classEntity.classType){
        param.append("classType",classEntity.classType);
    }
    this.$axios.post(crmUrl+'/ft/campus/getClassroom.do',param)
        .then(res => {
            classroomDialog.tableData = res.data.data;
            classroomDialog.dialogVisible = true;
    }, err => {
        proxy.$message.error(err);
        // this.$message.error('数据请求出错')
    });
};
let toXiao=()=>{
    closeTab();
    router.push('/showqrzclassmanage')
}

onActivated(()=>{
    // isUseCache为false时才重新刷新获取数据
    // 因为对list使用keep-alive来缓存组件，所以默认是会使用缓存数据的         
    if(route.meta.isUseCache == true){
        classEntity = {};
        getAreaList();
        getYears();
        getProductList();
        saveStatus.value = false;
    }
    // 通过这个控制刷新
    route.meta.isUseCache = false;
})

onBeforeRouteLeave((to, from ,next)=>{
    if (to.name == 'showqrzclassmanage') {
        // 根据是否删除操作，进行判断是否需要使用缓存数据\
        to.meta.isUseCache = isDel.value; 
        isDel.value=false;
    }
    else{
        to.meta.isUseCache = false;
    }       
    next();  
})



    // export default {
    //     name: 'addqrzclass',
    //     components: {inputNumber},
    //     data() {
    //         return {
    //             yearlist:[],
    //             areaList:[],
    //             officeList:[],
    //             productList:[],
    //             classroomDialog:{
    //                 dialogVisible:false,
    //                 officeId:'',
    //                 tableData:[]
    //             },
    //             courseCycDialog:{
    //                 dialogVisible:false,
    //                 tableData:[]
    //             },
    //             saveStatus:false,
    //             classEntity:{
    //                 classId:'',
    //                 className:'',
    //                 gradeStr:'',
    //                 grade:'',
    //                 areaId:'',
    //                 officeName:'',
    //                 officeId:'',
    //                 classType:'',
    //                 classLevelType:'',
    //                 subjectType:'',
    //                 status:'1',
    //                 masterId:'',
    //                 realname:'',
    //                 yearly:'',
    //                 productId:'',
    //                 productName:'',
    //                 paperType:'',
    //                 classroomId:'',
    //                 doorPlate:'',
    //                 courseCycId:'',
    //                 courseCycName:'',
    //                 salaryType:'',
    //                 // totalNum:'',
    //                 source:0
    //             },
    //             isDel:false,
    //             tagsList: [],
    //             classLevelList:[]//班级班型列表
    //         }
    //     },
    //     created() {
    //         this.getAreaList();
    //         this.getYears();
    //         this.getProductList();
    //         this.tagsList = this.tagsLists;
    //         this. getDictionList()
    //     },
    //     activated() {
    //         // isUseCache为false时才重新刷新获取数据
    //         // 因为对list使用keep-alive来缓存组件，所以默认是会使用缓存数据的         
    //         if(this.$route.meta.isUseCache == true){
    //             this.classEntity = {};
    //             this.getAreaList();
    //             this.getYears();
    //             this.getProductList();
    //             this.saveStatus = false;
    //         }
    //         // 通过这个控制刷新
    //         this.$route.meta.isUseCache = false;
    //     },
    //     computed: {
    //         ...mapGetters(['tagsLists'])            
    //     },
    //     mounted(){
    //         this.getEventData();
    //     },
    //     beforeRouteLeave (to, from, next) { 
    //         if (to.name == 'showqrzclassmanage') {
    //             // 根据是否删除操作，进行判断是否需要使用缓存数据\
    //             to.meta.isUseCache = this.isDel; 
    //             this.isDel=false;
    //         }
    //         else{
    //             to.meta.isUseCache = false;
    //         }       
    //         next();  
    //     },   
    //     methods: {
    //         ...mapMutations(['setTagsLists']),
    //         closeTab(){
    //             for (let i = 0, len = this.tagsList.length; i < len; i++) {
    //                 const item = this.tagsList[i];
    //                 if(item.path === this.$route.fullPath){
    //                     this.tagsList.splice(i, 1);
    //                     this.setTagsLists(this.tagsList);
    //                     break;
    //                 }
    //             }
    //         },
    //         getEventData(){
    //            /*  const that = this;
    //             bus.$on('tags', function(msg){
    //                 that.tagsList = msg;
    //             }); */
    //         },
    //         getYears(){
    //             //获取学年
    //             this.$axios.post(baseUrl+'/ft/campus/getSchoolYearList.do')
    //                 .then(res => {
    //                  if(res.data!=null&&res.data.code==0){
    //                       //获取菜单列表
    //                     this.yearlist = res.data.data;
    //                     this.yearlist.forEach(element => {
    //                         if(element.status != null && element.status == 1){
    //                             this.classEntity.yearly = element.value;
    //                         }
    //                     });
    //                  }else{
    //                     this.yearlist = [];
    //                  }
    //                 this.dataListLoading = false;
    //             }, err => {
    //                 this.$message.error(err);
    //             });
    //         },
    //         getProductList(){
    //         //获取产品线列表
    //             this.$axios.post(baseUrl+'/ft/campus/getProductList.do')
    //                 .then(res => {
    //                     if(res.data!=null&&res.data.code==0){
    //                         //获取菜单列表
    //                         this.productList = res.data.data;
    //                     }else{
    //                         this.productList = [];
    //                     }
    //                 this.dataListLoading = false;
    //             }, err => {
    //                 this.$message.error(err);
    //             });
    //         },
    //         getAreaList(){
    //              //业绩中心
    //             this.$axios.post(baseUrl+'/ft/campus/getSchoolAreaList.do')
    //                 .then(res => {
    //                     this.areaList = res.data.data;
    //             }, err => {
    //                 this.$message.error(err);
    //             });
    //             this.dataListLoading = false; 
    //         },
    //         changeArea(){
    //             this.officeList = [];
    //             this.classEntity.officeId = '';
    //             if(this.classEntity.areaId != null && this.classEntity.areaId != undefined){
    //                 let param = new URLSearchParams();
    //                 param.append("areaId",this.classEntity.areaId);
    //                  //授课地点
    //                 this.$axios.post(baseUrl+'/ft/campus/getOffices.do',param)
    //                     .then(res => {
    //                         this.officeList = res.data.data;
    //                 }, err => {
    //                     this.$message.error(err);
    //                 });
    //                 this.dataListLoading = false;
    //             }
    //         },
    //         changeClassType(){
    //             this.classEntity.subjectType = '';
    //         },           
    //         //获取字典表
    //         getDictionList(){
    //             this.classLevelList = [];//班级班型
    //             let param = new URLSearchParams();
    //             param.append('type', '162');
    //             this.$axios.post(baseUrl + '/ft/ftchoose/getDictionaryByType.do', param).then(res => {
    //                 //获取菜单列表
    //                 if(res.data.code == 0){
    //                     this.classLevelList = res.data.data;
    //                 }
    //             }, err => {
    //                 this.$message.error(err);
    //             });
    //         },
    //         addClassroom(){
    //             if(this.classEntity.yearly == null || this.classEntity.yearly === '' || this.classEntity.yearly == undefined){
    //                 this.$message.error('请先选择学年');
    //                 return;
    //             }

    //             if(this.classEntity.officeId == null || this.classEntity.officeId === '' || this.classEntity.officeId == undefined){
    //                 this.$message.error('请先选择授课地点');
    //                 return;
    //             }
    //             if(this.classEntity.classType == null || this.classEntity.classType === '' || this.classEntity.classType == undefined){
    //                 this.$message.error('请先选择班级类型');
    //                 return;
    //             }
    //             this.classroomDialog.officeId = this.classEntity.officeId;
    //             let param = new URLSearchParams();
    //             param.append("yearly",this.classEntity.yearly);
    //             param.append("officeId",this.classroomDialog.officeId);
    //             param.append("classType",this.classEntity.classType);
    //             this.$axios.post(baseUrl+'/ft/campus/getClassroom.do',param)
    //                 .then(res => {
    //                     this.classroomDialog.tableData = res.data.data;
    //                     this.classroomDialog.dialogVisible = true;
    //             }, err => {
    //                 this.$message.error(err);
    //                 this.$message.error('数据请求出错')
    //             });
    //         },
    //         addCourseCyc(){
    //             if(this.classEntity.yearly == null || this.classEntity.yearly == '' || this.classEntity.yearly == undefined){
    //                 this.$message.error('请先选择学年');
    //                 return;
    //             }
    //             let param = new URLSearchParams();
    //             param.append("yearly",this.classEntity.yearly);
    //             if(!(this.classEntity.productId === null || this.classEntity.productId === '' || this.classEntity.productId === undefined)){
    //                 param.append("productId",this.classEntity.productId);
    //             }
    //             if(!(this.classEntity.officeId === null || this.classEntity.officeId === '' || this.classEntity.officeId === undefined)){
    //                 param.append("officeId",this.classEntity.officeId);
    //             }
    //             this.$axios.post(baseUrl+'/ft/schoolcourse/getCourseCycleList.do',param)
    //                 .then(res => {
    //                     this.courseCycDialog.tableData = res.data.data;
    //                     this.courseCycDialog.dialogVisible = true;
    //             }, err => {
    //                 this.$message.error(err);
    //                 this.$message.error('数据请求出错')
    //             });
    //         },
    //         toSave(){
    //             this.saveStatus = true;
    //             if(this.classEntity.className == '' || this.classEntity.className == null || this.classEntity.className == undefined){
    //                 this.$message.error('请填写班级名称');
    //                 this.saveStatus = false;
    //                 return;
    //             }
    //             if(this.classEntity.yearly == '' || this.classEntity.yearly == null || this.classEntity.yearly == undefined){
    //                 this.$message.error('请选择学年');
    //                 this.saveStatus = false;
    //                 return;
    //             }
    //             if(this.classEntity.grade == '' || this.classEntity.grade == null || this.classEntity.grade == undefined){
    //                 this.$message.error('请选择年级');
    //                 this.saveStatus = false;
    //                 return;
    //             }
    //             if(this.classEntity.areaId == '' || this.classEntity.areaId == null || this.classEntity.areaId == undefined){
    //                 this.$message.error('请选择业绩中心');
    //                 this.saveStatus = false;
    //                 return;
    //             }
    //             if(this.classEntity.officeId == '' || this.classEntity.officeId == null || this.classEntity.officeId == undefined){
    //                 this.$message.error('请选择授课地点');
    //                 this.saveStatus = false;
    //                 return;
    //             }
    //             if(this.classEntity.productId == '' || this.classEntity.productId == null || this.classEntity.productId == undefined){
    //                 this.$message.error('请选择产品线');
    //                 this.saveStatus = false;
    //                 return;
    //             }
    //             if(this.classEntity.totalNum == '' || this.classEntity.totalNum == null || this.classEntity.totalNum == undefined){
    //                 this.$message.error('请填写额定人数');
    //                 this.saveStatus = false;
    //                 return;
    //             }
    //             if(this.classEntity.salaryType == '' || this.classEntity.salaryType == null || this.classEntity.salaryType == undefined){
    //                 this.$message.error('请选择课酬类型');
    //                 this.saveStatus = false;
    //                 return;
    //             }
    //             if(this.classEntity.classType == '' || this.classEntity.classType == null || this.classEntity.classType == undefined){
    //                 this.$message.error('请选择班级类型');
    //                 this.saveStatus = false;
    //                 return;
    //             }
    //             if(this.classEntity.classLevelType == '' || this.classEntity.classLevelType == null || this.classEntity.classLevelType == undefined){
    //                 this.$message.error('请选择班级班型');
    //                 this.saveStatus = false;
    //                 return;
    //             }
    //             if(this.classEntity.paperType === '' || this.classEntity.paperType === null || this.classEntity.paperType === undefined){
    //                 this.$message.error('请选择试卷类型');
    //                 this.saveStatus = false;
    //                 return;
    //             }
    //             if(this.classEntity.subjectType === '' || this.classEntity.subjectType === null || this.classEntity.subjectType === undefined){
    //                 this.$message.error('请选择班级科目');
    //                 this.saveStatus = false;
    //                 return;
    //             }
    //             if(this.classEntity.classType == 0){
    //                 if(this.classEntity.subjectType === '' || this.classEntity.subjectType == null || this.classEntity.subjectType == undefined){
    //                     this.$message.error('请选择班级科目');
    //                     this.saveStatus = false;
    //                     return;
    //                 }
    //                 if(this.classEntity.subjectType > 3){
    //                     this.$message.error('行政班不能选择单科');
    //                     this.saveStatus = false;
    //                     return;
    //                 }

    //             }else if(!(this.classEntity.subjectType === '' || this.classEntity.subjectType === null || this.classEntity.subjectType === undefined) && this.classEntity.subjectType < 3){
    //                 this.$message.error('教学班只能选择单科');
    //                 this.saveStatus = false;
    //                 return;
    //             }
    //             if(this.classEntity.status == '' || this.classEntity.status == null || this.classEntity.status == undefined){
    //                 this.$message.error('请选择状态');
    //                 this.saveStatus = false;
    //                 return;
    //             }
    //             if(this.classEntity.doorPlate == ''||this.classEntity.doorPlate == null || this.classEntity.doorPlate == undefined){
    //                 this.classEntity.classroomId = '';
    //             }
    //             if(this.classEntity.classType == 0 && ( this.classEntity.classroomId == '' || this.classEntity.classroomId === null || this.classEntity.classroomId === undefined)){
    //                 this.$message.error('请选择所在教室');
    //                 this.saveStatus = false;
    //                 return;
    //             }
    //             if(this.classEntity.courseCycId == '' || this.classEntity.courseCycId == null || this.classEntity.courseCycId == undefined){
    //                 this.$message.error('请关联上课周期');
    //                 this.saveStatus = false;
    //                 return;
    //             }
    //             let param = new URLSearchParams();
    //             param.append("className",this.classEntity.className);
    //             param.append("classType",this.classEntity.classType);
    //             param.append("bjbx",this.classEntity.classLevelType);
    //             param.append("grade",this.classEntity.grade);
    //             param.append("officeId",this.classEntity.officeId);
    //             param.append("areaId",this.classEntity.areaId);
    //             param.append("salaryType",this.classEntity.salaryType);
    //             param.append("studentNums",this.classEntity.totalNum);
    //             param.append("yearly",this.classEntity.yearly);
    //             param.append("productId",this.classEntity.productId);
    //             param.append("status",this.classEntity.status);
    //             param.append("paperType",this.classEntity.paperType);
    //             param.append("source",0);
    //             if(!( this.classEntity.classroomId === '' || this.classEntity.classroomId === null || this.classEntity.classroomId === undefined)){
    //                 param.append("classroomId",this.classEntity.classroomId);
    //             }
    //             param.append("courseCycId",this.classEntity.courseCycId);
    //             param.append("subjectType",this.classEntity.subjectType);
    //             this.$axios.post(baseUrl+'/ft/classmanage/saveClass.do',param)
    //                 .then(res => {
    //                     if(res.data.code === 0){
    //                         //保存成功
    //                         this.$message.success("保存成功！")
    //                         //返回前一个页面
    //                         this.closeTab();
    //                         this.isDel = true;
    //                         this.saveStatus = false;
    //                         this.$router.push('/showqrzclassmanage')
    //                     }else{
    //                         this.$message.error(res.data.msg);
    //                         this.saveStatus = false;
    //                         //留在当前页面
    //                     }
    //             }, err => {
    //                 this.$message.error(err);
    //                 this.$message.error('数据请求出错！')
    //                 this.saveStatus = false;
    //                 //this.closeTab();
    //                 //返回前一个页面
    //                 this.$router.push('/showqrzclassmanage')
    //             });

    //         },
    //         confirmClassroom(index,row){
    //             this.classEntity.classroomId = row.classroomId;
    //             this.classEntity.doorPlate = row.doorPlate;
    //             this.classroomDialog.dialogVisible = false;

    //         },
    //         confirmCourseCyc(index,row){
    //             this.classEntity.courseCycId = row.id;
    //             this.classEntity.courseCycName = row.name;
    //             this.courseCycDialog.dialogVisible = false;
    //         },
    //         checkNum(){
    //             let patern = /^(\-|\+)?\d+(\.\d+)?$/;//验证正数、负数、小数
    //             let font = this.classEntity.totalNum + '';
    //             if(font.endsWith('.') ){
    //                 font = font.substr(0,font.length-1);
    //             }
    //             if(font.indexOf('.')==0){
    //                 if(!patern.test(parseFloat(font))){
    //                     this.classEntity.totalNum = '';
    //                 }
    //             }else{
    //                 if(!patern.test(parseInt(font))){
    //                     this.classEntity.totalNum = '';
    //                 }
    //             }
    //         },
    //         searchClassroom(){
    //              if(this.classroomDialog.officeId == null || this.classroomDialog.officeId == '' || this.classroomDialog.officeId == undefined){
    //                 this.$message.error('请先选择办公地点');
    //                 return;
    //             }
    //             let param = new URLSearchParams();
    //             if(this.classEntity.yearly != null && this.classEntity.yearly != undefined){
    //                 param.append("yearly",this.classEntity.yearly);
    //             }
    //             param.append("officeId",this.classroomDialog.officeId);
    //             if(this.classEntity.classType != null && this.classEntity.classType != undefined){
    //                 param.append("classType",this.classEntity.classType);
    //             }
    //             this.$axios.post(baseUrl+'/ft/campus/getClassroom.do',param)
    //                 .then(res => {
    //                     this.classroomDialog.tableData = res.data.data;
    //                     this.classroomDialog.dialogVisible = true;
    //             }, err => {
    //                 this.$message.error(err);
    //                 this.$message.error('数据请求出错')
    //             });
    //         },
    //         toXiao(){
    //             this.closeTab();
    //             this.$router.push('/showqrzclassmanage')
    //         }
    //     }
    // }

</script>

<style scoped>
    .cons{
        width: 80%;
        margin: 0 auto;
        border: 1px solid #e8e8e8;
    }
    .con-title{
        padding-bottom: 10px;
        padding-top: 20px;
        text-align: center;
    }
    .lie-title{
        width: 100px;
        display: inline-block;
        text-align: right;
        margin-right:10px
    }
    .con-item{
        margin-top: 20px;
    }
    .red-x{
        color: red;
        margin-right: 8px;
    }
    /* .text-input{
        width: 215px;
    } */
    .select{
        width: 30%;
    }
    .ts-text{
        color: red;
        font-size: 12px;
        margin-left: 100px;
        margin-top: 10px;
    }
    .div-btn{
        width: 100%;
        text-align: center;
        padding-bottom: 10px;
    }
    .el-btn{
        width: 100px;
        margin-top: 30px;
    }
    .editor{
        width: 80%;
        display: inline-block;
    }
    .el-add{
        font-size: 18px;
    }
    .left-20px{
       margin-left: 20px; 
    }
    .zl-dialog .el-select.el-select--small, 
    .zl-dialog .el-date-editor--date
   {
        width: 70% !important;
    }
    .covered .el-input__suffix{
       right: 40px !important;
    }
    .zl-dialog .covered.el-input{
        width: 73% !important;
    }
    .addInputs{
        width: 70%;
        display: inline-block;
    }
    .el-dialog-div{
        height: 320px;
        overflow-y: auto;
    }
</style>
<style>
    .ql-container{
        min-height: 200px;
    }
</style>